package com.cnyao.phot;

import java.util.Date;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.CallLog.Calls;
import android.widget.ListView;

public class CallLogListActivity extends Activity {
	private CallLogAdapter mAdapter;
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.call_log_list);
		mAdapter=new CallLogAdapter(this, InitializeCursor());
		final ListView lview=(ListView)findViewById(R.id.callLogList);
		lview.setAdapter(mAdapter);
	}

	private Cursor InitializeCursor() {
		Date dt=new Date();
		dt.setDate(1);
		long ltime=dt.getTime();
		String[] projection={Calls._ID,Calls.NUMBER,Calls.TYPE,Calls.DURATION,Calls.DATE};
		
		Cursor cursor=getContentResolver().query(Calls.CONTENT_URI, 
				projection, Calls.DATE+">"+ltime, null, Calls.DATE+" ASC");
		return cursor;
	}
}
